//
//  HX_TableViewCell.m
//  UI10-易车
//
//  Created by 韩旭 on 16/7/27.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "HX_TableViewCell.h"

@implementation HX_TableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    [self creatBtn];
    return self;
}
- (void)creatBtn {
    
    _btnBuyCar = [UIButton buttonWithType:UIButtonTypeCustom];
    _btnBuyCar.frame = CGRectZero;
    CGFloat midTop = 0;
    CGFloat midLeft = 25;
    CGFloat midBottom = 40;
    CGFloat midRight = 20;
    CGFloat midTopTitle = 50;
    CGFloat midLeftTitle = -100;
    CGFloat midBottomTitle = 0;
    CGFloat midRightTitle = 10;
    _btnBuyCar.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.00];
    [_btnBuyCar setTitle:@"贷款买车" forState:UIControlStateNormal];
    
    [_btnBuyCar setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [_btnBuyCar setImage:[UIImage imageNamed:@"1"] forState:UIControlStateNormal];
    _btnBuyCar.imageEdgeInsets = UIEdgeInsetsMake(midTop, midLeft, midBottom, midRight);
    _btnBuyCar.titleEdgeInsets = UIEdgeInsetsMake(midTopTitle, midLeftTitle, midBottomTitle, midRightTitle);
    [self.contentView addSubview:_btnBuyCar];
    
    _btnSell = [UIButton buttonWithType:UIButtonTypeCustom];
    _btnSell.frame = CGRectZero;
    _btnSell.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.00];
    [_btnSell setImage:[UIImage imageNamed:@"2"] forState:UIControlStateNormal];
    [_btnSell setTitle:@"直销车型" forState:UIControlStateNormal];
    [_btnSell setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    _btnSell.imageEdgeInsets = UIEdgeInsetsMake(midTop, midLeft, midBottom, midRight);
    _btnSell.titleEdgeInsets = UIEdgeInsetsMake(midTopTitle, midLeftTitle, midBottomTitle, midRightTitle);
    [self.contentView addSubview:_btnSell];
    
    _btnLow = [UIButton buttonWithType:UIButtonTypeCustom];
    _btnLow.frame = CGRectZero;
    _btnLow.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.00];
    [_btnLow setImage:[UIImage imageNamed:@"3"] forState:UIControlStateNormal];
    [_btnLow setTitle:@"低价买车" forState:UIControlStateNormal];
    [_btnLow setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    _btnLow.imageEdgeInsets = UIEdgeInsetsMake(midTop, midLeft, midBottom, midRight);
    _btnLow.titleEdgeInsets = UIEdgeInsetsMake(midTopTitle, midLeftTitle, midBottomTitle, midRightTitle);
    [self.contentView addSubview:_btnLow];
    
    _btnUserCar = [[UIButton alloc] initWithFrame:CGRectZero];
    [_btnUserCar setImage:[UIImage imageNamed:@"4"] forState:UIControlStateNormal];
    [_btnUserCar setTitle:@"二手车" forState:UIControlStateNormal];
    [_btnUserCar setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    _btnUserCar.imageEdgeInsets = UIEdgeInsetsMake(midTop, midLeft, midBottom, midRight);
    _btnUserCar.titleEdgeInsets = UIEdgeInsetsMake(midTopTitle, midLeftTitle, midBottomTitle, midRightTitle);
    _btnUserCar.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.00];
    [self.contentView addSubview:_btnUserCar];
}
- (void)layoutSubviews {
    [super layoutSubviews];
//   button 个数
     CGFloat n = 4.0;
    
    _btnBuyCar.frame = CGRectMake(0, 0, self.contentView.frame.size.width / n, self.contentView.frame.size.height);
    _btnSell.frame = CGRectMake(_btnBuyCar.frame.size.width, 0, _btnBuyCar.frame.size.width, _btnBuyCar.frame.size.height);
    _btnLow.frame = CGRectMake(_btnSell.frame.origin.x + _btnSell.frame.size.width, 0, _btnSell.frame.size.width, _btnSell.frame.size.height);
    _btnUserCar.frame = CGRectMake(_btnLow.frame.size.width + _btnLow.frame.origin.x, 0, _btnLow.frame.size.width, _btnLow.frame.size.height);
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
